#include<iostream>
#include<string>
#include<cmath>
#include<set>
using namespace std;
typedef long long LL;
set<LL>S1, S2, S3;
int a, b;
int main()
{
	cin >> a >> b;
	for (int i = 1; i * i <= a; i++) {
		if (a % i == 0) {
			S1.insert(i);
			if (i != a / i) {
				S1.insert(a / i);
			}
		}
	}
	for (int i = 1; i * i <= b; i++) {
		if (b % i == 0) {
			S2.insert(i);
			if (i != b / i) {
				S2.insert(b / i);
			}
		}
	}
	for (auto x : S1) {
		for (auto y : S2) {
			S3.insert(1ll * x * y);
		}
	}
	cout << S3.size() << endl;
	for (auto x : S3) {
		cout << x << " ";
	}
	return 0;
}